<!DOCTYPE html>
<html>
<head>
    <title>修旧利废记录</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="2">
                    <i-select v-model="q.expUnit" placeholder="请选择所属车间">
                        <i-option v-for="workshop in workshopList" :value="workshop.deptId" :key="workshop.deptId">
                            {{workshop.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="2">
                    <i-select v-model="q.btUnit" placeholder="请选择所属车间">
                        <i-option v-for="workshop in workshopList" :value="workshop.deptId" :key="workshop.deptId">
                            {{workshop.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.name" @on-enter="query" placeholder="备件名称"></i-input>
                </i-col>
                <i-col span="2">
                    <i-select v-model="q.isFixed" placeholder="请选择状态">
                        <i-option v-for="item in statusList" :value="item.value" :key="item.value">{{item.name}}</i-option>
                    </i-select>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.spec" @on-enter="query" placeholder="备件规格"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.partCode" @on-enter="query" placeholder="备件编码"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.erpCode" @on-enter="query" placeholder="ERP编码"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.producor" @on-enter="query" placeholder="生产厂家"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.repairUserName" @on-enter="query" placeholder="维修人员姓名"></i-input>
                </i-col>

                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <Row :gutter="16" style="margin: 3px 0px 0px 0px;">
            <div class="buttons-group">
                #if($shiro.hasPermission("devretreadrecord:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("devretreadrecord:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;完善维修记录
                </i-button>
                #end
                #if($shiro.hasPermission("devretreadrecord:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>

    <Card v-show="!showList">
        <div  slot="title" v-show="isShow = 1">{{title}}&nbsp;<button style="border-style: none;" @click="orderDetails" v-show="isShow == 1"><i class="fa fa-eye"></i></button></div>
        <i-form ref="formValidate" :model="devRetreadRecord" :rules="ruleValidate" :label-width="110">
            <Row>
                <i-col span="12">
                    <Form-item label="物料名称" prop="materName">
                        <i-input v-model="devRetreadRecord.materName" placeholder="物料名称"
                                 ref="materialNameInput" icon="md-arrow-dropdown-circle" @on-click="getSpareInfo"
                                 icon="md-arrow-dropdown-circle"></i-input>
                        <i-input v-model="devRetreadRecord.spareId" v-show="false"></i-input>
                        <!--
                                                <i-input v-model="devRetreadRecord.materName" placeholder="备件名称" disabled></i-input>
                        -->
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item label="物料编码" prop="matterCode">
                        <i-input v-model="devRetreadRecord.matterCode" placeholder="物料编码" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="12">
                    <Form-item label="单位" prop="materUnit">
                        <i-input v-model="devRetreadRecord.materUnit" placeholder="单位" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item label="规格型号" prop="expUnitName">
                        <i-input v-model="devRetreadRecord.materSpec" placeholder="规格型号" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="12">
                    <Form-item label="零件原值" prop="origVal">
                        <i-input v-model="devRetreadRecord.origVal" placeholder="零件原值" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item label="数量" prop="retNum">
                        <input-number :min="0" v-model="devRetreadRecord.retNum" placeholder="数量"
                                      style="width: 100%"></input-number>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="12">
                    <Form-item label="是否修复" prop="isFixed" v-show="isShow == 1">
                        <Radio-group v-model="devRetreadRecord.isFixed">
                            <Radio :label="1"><span>是</span></Radio>
                            <Radio :label="2"><span>否</span></Radio>
                        </Radio-group>
                    </Form-item>
                    <Form-item label="维修人员名称" prop="repairUserName" v-show="devRetreadRecord.isFixed === 1">
                        <i-input v-model="devRetreadRecord.repairUserName" placeholder="维修人员名称"></i-input>
                    </Form-item>
                    <Form-item label="修理办法" prop="repairMethod" >
                        <i-input v-model="devRetreadRecord.repairMethod" placeholder="修理办法" type="textarea"></i-input>
                    </Form-item>
                    <Form-item label="维修成本" prop="primeCost" v-show="devRetreadRecord.isFixed === 1">
                        <i-input v-model="devRetreadRecord.primeCost"
                                 placeholder="不填时默认通过换件记录进行计算"></i-input>
                    </Form-item>
                    <Form-item label="申报节约价值" prop="lessCost" v-show="devRetreadRecord.isFixed === 1">
                        <i-input v-model="devRetreadRecord.lessCost" placeholder="申报节约价值"></i-input>
                    </Form-item>
                    <Form-item label="备注信息" prop="remark">
                        <i-input v-model="devRetreadRecord.remark" placeholder="备注信息" type="textarea"></i-input>
                    </Form-item>

                </i-col>
                <i-col span="12">
                    <Form-item label="后续处理" prop="isFixed" v-show="isShow == 1 && devRetreadRecord.isFixed !== 1">
                        <Radio-group v-model="devRetreadRecord.isFixed">
                            <Radio :label="3"><span>报废</span></Radio>
                            <Radio :label="4"><span>委外维修</span></Radio>
                        </Radio-group>
                    </Form-item>
                    <Form-item label="换件记录" v-show="devRetreadRecord.isFixed === 1">
                        <Card>
                            <div style="margin-bottom: 5px">
                                <i-button type="info" @click="getSparePart"><i class="fa fa-plus"></i>&nbsp;选择备件</i-button>
                                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                            </div>
                            <div>
                                <table id="swapRecord"></table>
                            </div>
                        </Card>
                    </Form-item>
                    <Form-item label="附件记录" v-show="devRetreadRecord.isFixed === 1">
                        <Card>
                            <p slot="title">
                                附件列表
                            </p>
                            #if($shiro.hasAnyRole("RL13","RL23"))
                            <div style="margin-bottom: 5px">
                                <i-button type="info" @click="annexModalShow"><i class="fa fa-plus"></i>&nbsp;上传附件</i-button>
                                <i-button type="error" @click="delAnnexList"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                            </div>
                            #end
                            <div>
                                <table id="annexList"></table>
                            </div>
                        </Card>
                    </Form-item>
                </i-col>
            </Row>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px">返回</i-button>
                <i-button type="info" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
    </Card>
    <!-- 详情列表区域 -->
    <div id="auditHistoryArea" style="display: none;">
        <table id="swapRecordDetail"></table>
    </div>
    <!--上传附近列表-->
    <Modal
            v-model="annexListShow"
            title="请上传附件"
            @on-ok="annexSubmit"
            @on-cancel="annexCancel">
        <div style="display: flex">
            <div style="flex-basis: 12%;display: flex;align-items: center">
                附件名称
            </div>
            <div style="flex-basis: 88%">
                <i-input v-model="annexFile.fileName" placeholder="附件标题" readonly></i-input>
            </div>
        </div>
        <div style="display: flex;margin-top: 15px;">
            <div style="flex-basis: 12%;display: flex;align-items: center">
                文件路径
            </div>
            <div style="flex-basis: 88%;display: flex">
                <div style="flex-basis: 80%;">
                    <div style="width: 100%">
                        <i-input v-model="annexFile.url" placeholder="上传附件后自动填写，建议优先上传PDF文件" readonly ></i-input>
                    </div>
                </div>
                <div style="flex-basis: 20%">
                    <Upload
                            ref="uploadFile"
                            action="../sys/oss/device/file"
                            :before-upload="handleBeforeUpload"
                            :on-success="handleSuccess"
                            :show-upload-list="false"
                            :on-exceeded-size="handleMaxSize">
                        <i-button icon="ios-cloud-upload-outline">上传</i-button>
                    </Upload>
                </div>
            </div>
        </div>
    </Modal>
</div>

<script src="${rc.contextPath}/js/device/devretreadrecord.js?_${date.systemTime}"></script>
</body>
</html>
